package com.mm.bo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * @ClassName EmployeeSearchBo
 * @Description TODO
 * @Author 任昊
 * @Date 2020/12/4 10:56
 */
@Data
@ApiModel(value = "查询员工入参", description = "查询员工入参")
public class EmployeeSearchBo {

    @ApiModelProperty(value = "查询条件(工号、姓名)", example = "工号、姓名")
    private String searchInfo;

    @ApiModelProperty(value = "员工状态(1-在职、0-离职)", example = "1-在职、0-离职", required = true)
    private Long empWorkStatus;

    @ApiModelProperty(value = "查询条件(起始时间)", example = "起始时间")
    private Long beginTime;

    @ApiModelProperty(value = "查询条件(结束时间)", example = "结束时间")
    private Long endTime;

    @ApiModelProperty(value = "当前页", example = "1", required = true)
    @NotNull(message = "pageIndex不能为空")
    @Min(value = 1, message = "pageIndex最小为1")
    private Integer pageIndex;

    @ApiModelProperty(value = "当前页大小", example = "10", required = true)
    @NotNull(message = "pageSize不能为空")
    @Min(value = 1, message = "pageSize最小为1")
    private Integer pageSize;

    public Integer getPageIndex() {
        if (pageIndex < 1) {
            pageIndex = 0;
            return pageIndex;
        } else {
            return (pageIndex - 1) * pageSize;
        }
    }
}
